#include <iostream>
using namespace std;
class People
{

public:
    char name;
    People(char name) : name{name}
    {
    }
};
class Student : public People
{
public:
    int classNo;
    Student(char name, int classNo) : People{name}, classNo{classNo}
    {
    }
};

int main()
{
    // “通过基类指针访问派生类对象中的基类子对象”
    People *q;
    People p1('A');
    Student s1('B', 2);
    q = &p1;
    cout << q->name << endl;
    q = &s1;
    cout << q->name << endl;
    // 基类指针指向派生类对象，但访问的是基类成员”，没有多态，静态绑定，编译期就决定访问的是基类的成员
    //  error: ‘class People’ has no member named ‘classNo’
    // cout << q->classNo << endl;
    return 0;
}
